#include "config_task.h"

TaskHandle_t configHandler;

extern QueueHandle_t configMsgHandle;
//用来去书写 心跳任务需要外设进行初始化	
void init_config(){
   config_eepprom_init();
}

void dispatchMsg(msg);

void config_task(void * param){

    char *msg;
    while (1)
    {
       if(xQueueReceive(configMsgHandle,&msg,portMAX_DELAY)==pdTRUE){
            //根据消息的类型进行区分去处理
            dispatchMsg(msg);
       }

        vTaskDelay(2000);
    }
    
}

void createConfigTask(){
    xTaskCreate(
        config_task,
        "config_task",
        128,
        NULL,
        2,
        &configHandler
    );
}


void dispatchMsg(char *msg){
    //1.获取消息类型
    int type= parseMsgType(msg);
    //2.根据消息类型 做处理
    switch (type)
    {
    case MSG_TYPE_CONFIG_TH:
        //调用处理阈值类配置的函数
        configTh(msg);
        break;
    case MSG_TYPE_CONFIG_NETWORK:
        //调用处理网络类配置函数
        configNetwork(msg);
        break;    
    
    default:
        break;
    }
}
